<template>
  <div class="bedtable_add">
    <div class="bedtable">
      <el-form :model="bedtableList" label-width="120px">
        <el-form-item label="床位编号">
          <el-input v-model="bedtableList.bednumber" />
        </el-form-item>
        <el-form-item label="所属科室">
          <el-select v-model="bedtableList.department">
            <el-option label="急诊科" value="急诊科" />
            <el-option label="妇产科" value="妇产科" />
            <el-option label="神经科" value="神经科" />
            <el-option label="脑外科" value="脑外科" />
          </el-select>
        </el-form-item>
        <el-form-item label="氧气罐">
          <el-radio-group v-model="bedtableList.oxygen">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="心电机">
          <el-radio-group v-model="bedtableList.heart">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="呼吸机">
          <el-radio-group v-model="bedtableList.breath">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="急救设备">
          <el-radio-group v-model="bedtableList.icu">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="空调地暖">
          <el-radio-group v-model="bedtableList.aircondition">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="电视外设">
          <el-radio-group v-model="bedtableList.tv">
            <el-radio label="1">是</el-radio>
            <el-radio label="0">否</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="责任护士">
          <el-input v-model="bedtableList.nurse" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">确认创建</el-button>
          <el-button type="info">返回上一级</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive } from "vue";
import { bedtableAddReq } from "../../api/bedtable.api";
import { ElMessage } from "element-plus";
const bedtableList = reactive({
  bednumber: "",
  department: "",
  oxygen: null,
  heart: null,
  breath: null,
  icu: null,
  aircondition: null,
  tv: null,
  nurse: "",
});
// 点击创建
const onSubmit = async () => {
  if (
    bedtableList.bednumber == "" ||
    bedtableList.department == "" ||
    bedtableList.oxygen == "" ||
    bedtableList.heart == "" ||
    bedtableList.breath == "" ||
    bedtableList.icu == "" ||
    bedtableList.aircondition == "" ||
    bedtableList.tv == "" ||
    bedtableList.nurse == ""
  ) {
    ElMessage.error("请将床位信息填写完整！");
    return;
  }
  const res = await bedtableAddReq(bedtableList);
  if (res.data.code == 1) {
    ElMessage({
      message: res.data.msg,
      type: "success",
    });
    bedtableList.bednumber = "";
    bedtableList.department = "";
    bedtableList.oxygen = null;
    bedtableList.heart = null;
    bedtableList.breath = null;
    bedtableList.icu = null;
    bedtableList.aircondition = null;
    bedtableList.tv = null;
    bedtableList.nurse = "";
  } else {
    ElMessage.error(res.data.msg);
  }
  //   console.log(res, "222");
};
</script>

<style scoped lang="scss">
.bedtable_add {
  width: 100%;
  height: 100%;
  .bedtable {
    width: 500px;
    height: 100%;
  }
}
</style>
